<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-11-09 11:31:58
         compiled from "H:\WebApplication\myconpany\sumi_mobile\application\views\shopcart\index.html" */ ?>
<?php /*%%SmartyHeaderCode:3377561b283d738083-05614494%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    'c3f7796ee446d9f427131448523c78bc6c9d7913' => 
    array (
      0 => 'H:\\WebApplication\\myconpany\\sumi_mobile\\application\\views\\shopcart\\index.html',
      1 => 1447037685,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '3377561b283d738083-05614494',
  'function' => 
  array (
  ),
  'version' => 'Smarty-3.1.21-dev',
  'unifunc' => 'content_561b283d8b3fc1_57841549',
  'variables' => 
  array (
    'user_action' => 0,
    'contacts' => 0,
    'conpanylist' => 0,
    'item' => 0,
    'order_info' => 0,
    'product' => 0,
  ),
  'has_nocache_code' => false,
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_561b283d8b3fc1_57841549')) {function content_561b283d8b3fc1_57841549($_smarty_tpl) {?><?php echo $_smarty_tpl->getSubTemplate ((@constant('APPLICATION_PATH')).("/application/views/header.html"), $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>

<?php echo $_smarty_tpl->getSubTemplate ((@constant('APPLICATION_PATH')).("/application/views/common/headertitle.html"), $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>


<div style="height:48px;"></div>
<section class="wp_fixed">
    <p class="self-stock-title bff"><span class="orange">配送方式</span></p>
    <p class="tgb_radio delivery ">
        <label class="pr10p j_psn"><input name="zt" type="radio" class="btn_radio" <?php if ($_smarty_tpl->tpl_vars['user_action']->value['area_id']=='T') {?>checked="checked"<?php }?> value="T"> 自提</label>
        <label class="pr10p j_ps"><input name="zt" class="btn_radio" <?php if ($_smarty_tpl->tpl_vars['user_action']->value['area_id']=='S') {?>checked="checked"<?php }?>  type="radio" value="S"> 配送</label>
        <input type="text" name="delivery_addr" style="border: 1px solid #ddd; line-height: 26px; padding: 1px 5px;" placeholder="请输入您的配送地址！" value="" class="j_pssh delivery_addr <?php if ($_smarty_tpl->tpl_vars['user_action']->value['area_id']=='T') {?>dn<?php }?> ml10 sp_int">
    </p>

    <div class="tgb_wrmg">
        <p class="self-stock-title bff"><span class="orange">联系信息</span></p>
        <ul class="to-c" style="background:#fff;">

            <?php if ($_smarty_tpl->tpl_vars['contacts']->value=='') {?>
            <li class="conpany" value="1"><span class="">公司名称：</span><input type="text" value="" name="business_name" class="to-c-fp"></li>
            <li><span class="">联 系 人 ：</span><input type="text" name="contacts" class="to-c-fp" placeholder="请填写联系人"/></li>
            <li><span class="">手机号码：</span><input type="text" name="mobile" class="to-c-fp" placeholder="请填写手机号码"/></li>
            <?php } else { ?>
            <li class="conpany" value="2"><span class="sp_ts">选择公司：</span>
                <select name="sup_id" class="to-c-fp" id="select">
                    <?php  $_smarty_tpl->tpl_vars['item'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['item']->_loop = false;
 $_smarty_tpl->tpl_vars['key'] = new Smarty_Variable;
 $_from = $_smarty_tpl->tpl_vars['conpanylist']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['item']->key => $_smarty_tpl->tpl_vars['item']->value) {
$_smarty_tpl->tpl_vars['item']->_loop = true;
 $_smarty_tpl->tpl_vars['key']->value = $_smarty_tpl->tpl_vars['item']->key;
?>
                    <option value="<?php echo $_smarty_tpl->tpl_vars['item']->value['id'];?>
" <?php if ($_smarty_tpl->tpl_vars['item']->value['is_default']=='Y') {?>selected<?php }?>><?php echo $_smarty_tpl->tpl_vars['item']->value['business_name'];?>
</option>
                    <?php } ?>
                </select>
            </li>
            <li><span class="">联 系 人 ：</span><span class="text_contacts"><?php echo $_smarty_tpl->tpl_vars['contacts']->value['contacts'];?>
</span></li>
            <li><span class="">手机号码：</span><span class="text_mobile"><?php echo $_smarty_tpl->tpl_vars['contacts']->value['mobile'];?>
</span></li>
            <?php }?>
        </ul>
    </div>

    <div class="self-stock mt10p">

        <?php  $_smarty_tpl->tpl_vars['item'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['item']->_loop = false;
 $_smarty_tpl->tpl_vars['key'] = new Smarty_Variable;
 $_from = $_smarty_tpl->tpl_vars['order_info']->value['order_sku']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['item']->key => $_smarty_tpl->tpl_vars['item']->value) {
$_smarty_tpl->tpl_vars['item']->_loop = true;
 $_smarty_tpl->tpl_vars['key']->value = $_smarty_tpl->tpl_vars['item']->key;
?>
        <p class="self-stock-title bff"><span class="orange">商品清单</span></p>
        <p class="self-stock-title"><?php echo $_smarty_tpl->tpl_vars['item']->value['cate_name'];?>
 <?php echo $_smarty_tpl->tpl_vars['item']->value['product_name'];?>
 <?php echo $_smarty_tpl->tpl_vars['item']->value['brand_name'];?>
 </p>
        <p class="fs14p orange pl10p pt10p"><span class="fs14p"><?php echo $_smarty_tpl->tpl_vars['item']->value['currency_mark'];?>
 </span><?php echo $_smarty_tpl->tpl_vars['item']->value['price'];?>
<span class="fs14p">元/吨</span></p>
        <p class="sst-te"><span class="sst-te2">厂商：<?php echo $_smarty_tpl->tpl_vars['item']->value['brand_name'];?>
</span><span class="sst-te1">产品类型：<?php echo $_smarty_tpl->tpl_vars['item']->value['service_name'];?>
</span></p>
        <p class="sst-te"><span class="sst-te2">交货时间：<?php echo $_smarty_tpl->tpl_vars['item']->value['delivery_time'];?>
</span><span class="sst-te1">交货地点：<?php echo $_smarty_tpl->tpl_vars['item']->value['delivery_area'];?>
</span></p>
        <?php if ($_smarty_tpl->tpl_vars['item']->value['settlement']!='') {?><p class="sst-te"><span class="sst-te1">结算方式：<?php echo $_smarty_tpl->tpl_vars['item']->value['settlement'];?>
</span></p><?php }?>
        <ul class="to-c" style="background:#fff;">
            <li><span>数量：</span><input name="product_num" num="<?php echo $_smarty_tpl->tpl_vars['item']->value['real_num'];?>
" price="<?php echo $_smarty_tpl->tpl_vars['item']->value['price'];?>
" product_id="<?php echo $_smarty_tpl->tpl_vars['item']->value['product_id'];?>
" type="text" class="to-c-fp product_num" style="min-width:80px;width:80px;" value="5" placeholder="请填写数量"/>/吨</li>
        </ul>
        <?php } ?>
        <p class="sale_zr">应付总额：<span class="orange fwb "><?php echo $_smarty_tpl->tpl_vars['product']->value['currency_mark'];?>
</span> <span class="orange fwb total_price"><?php echo $_smarty_tpl->tpl_vars['product']->value['price']*5;?>
</span></p>
        <div class="sub-order "><a href="#">提交订单</a></div>

    </div>



</section>


<?php echo '<script'; ?>
 typte="text/javascript">
    $(function(){
        $('.j_ps').click(function(){
            $('.j_pssh').show();
        });
        $('.j_psn').click(function(){
            $('.j_pssh').hide();
        });


        //更新配送方式
        $(".btn_radio").click(function(){
            var dm = $("input[name='zt']:checked").val();
            var dr = $("input[name='delivery_addr']").val();
            $.ajax({
                url:'/shopcart/delivery',
                data:{dm:dm,dr:dr},
                type:'POST',
                success:function(data){
                    return true;
                },
                dataType:'text'
            });
        });

        $(".delivery_addr").blur(function(){
            var dr = $("input[name='delivery_addr']").val();

            $.ajax({
                url:'/shopcart/delivery_addr',
                data:{dr:dr},
                type:'POST',
                success:function(data){
                    return;
                },
                dataType:'text'
            });
        });

        //选择公司
        $("#select").change(function(){
            var select_id=$("#select option:selected").val();

            $.ajax({
                url:'/shopcart/user_invoice',
                data:{select_id:select_id},
                type:'POST',
                success:function(data){
                    data = eval("("+data+")");
                    if(data.code == 8 ){
                        var d = data.data;
                        $('input[name="business_name"]').val(d.business_name);
                        $('input[name="business_remarks"]').val(d.business_remarks);
                        $('input[name="business_phone"]').val(d.business_phone);
                        $('.text_contacts').text(d.contacts);
                        $('.text_mobile').text(d.mobile);
                    }
                },
                dataType:'text'
            });
        });


        $('input.product_num').change(function(){
            var pn = $(this);
            var tp = $(".total_price");
            var product_num = parseFloat(pn.val());
            var real_num = parseFloat(pn.attr('num'));
            var price = pn.attr('price');

            if(product_num < 1){
                alert("数量不可少于1吨！");
                pn.val("1");
                product_num = pn.val();
                tp.text(product_num*price);
            }

            if(product_num > real_num){
                alert("不可超过可售数量！");
                pn.val(real_num);
                product_num = pn.val();
                tp.text(product_num*price);
                //开始更新数量
                update_product_num(product_num)
            }else{
                product_num = pn.val();
                tp.text(product_num*price);
                update_product_num(product_num)
            }
        });

        function update_product_num(product_num){
            $.ajax({
                url:'/shopcart/updatenum',
                data:{product_num:product_num},
                type:'POST',
                success:function(data){
                    return;
                },
                dataType:'text'
            });
        }

        $('.sub-order').click(function(){ //去结算，提交跟新购物车
            var cp = $(".conpany").attr("value");

            if(cp === 1){
                var bn = $("input[name=business_name]").val();
                var ct = $("input[name=contacts]").val();
                var mb = $("input[name=mobile]").val();

                if(bn == '' && bn.length>8){
                    alert("请维护正确公司名称！");
                    return false;
                }

                if(ct == ''){
                    alert("请维护正确联系人！");
                    return false;
                }

                if(mb =='' && !mb.match(/^(?:13\d|15\d|18\d)\d{5}(\d{3}|\*{3})$/)){
                    alert("请维护正确手机号码！");
                    return false;
                }

                $.ajax({
                    url:'/shopcart/addinvoice',
                    data:{business_name:bn,contacts:ct,mobile:mb},
                    type:'POST',
                    async:false,
                    success:function(data){
                        data = eval("("+data+")");
                        if(data.code == 8 ){
                            var url = "/shopcart/createorder";
                            window.location = url;
                            return true;
                        }else{
                            alert(data.msg);
                            return false;
                        }
                    },
                    dataType:'text'
                });

            }else{
                var url = "/shopcart/createorder";
                window.location = url;
            }


        });
    });
<?php echo '</script'; ?>
>


<?php }} ?>
